package com.hyt.it.ogt.ks.mapper;

import java.time.LocalDateTime;
import java.util.List;

import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.hyt.it.ogt.ks.model.entity.CandidateProcess;
import com.hyt.it.ogt.ks.model.entity.CandidateTimeLength;

/**
 * <p>
 * 考生考试过程表 Mapper 接口
 * </p>
 *
 * @author chengxh
 * @since 2020-06-17
 */
public interface CandidateProcessMapper extends BaseMapper<CandidateProcess> {

    /**
     * 登录时插入过程表数据
     * @param candidateProcess
     * @return
     */
    int insertCandidateProcess(CandidateProcess candidateProcess);

    /**
     * 获取考试过程信息
     * @param candidateId
     * @return
     */
    CandidateProcess getCandidateProcess(String examId, String candidateId);

    /**
     * 更新试卷数据到过程表
     * @param candidateProcess
     * @return
     */
    int updatePaperInfo(CandidateProcess candidateProcess);

    /**
     * 批量更新剩余时间
     * @param candidateIds
     */
    void submitPaper(@Param("candidateIds") List<String> candidateIds);

    /**.
     * 更新考生信息
     * @param candidateProcess
     * @param query
     * @return
     */
    int updateCandidateProcess(CandidateProcess candidateProcess, @Param(Constants.WRAPPER)QueryWrapper<CandidateProcess> query);

    /**
     * 更新考生状态
     * @param newStatus
     * @param oldStatus
     * @param candidateId
     * @param examId
     * @return
     */
    int updateInterruptStatus(Integer newStatus, Integer oldStatus, String candidateId, String examId);

    /**
     * 撤销交卷
     * @param examId
     * @param candidateId
     * @return
     */
    int cancelSubmitPaper(String examId, String candidateId);


    int updateObjectiveScore(List<CandidateProcess> candidateProcessList);

    int updateBeginTimeById(String id, LocalDateTime startTime);

    int updateExamStatusById(String id, Integer status);

    List<CandidateTimeLength> getMonitorScreen(String examId);

    /**
     *获取需要分页所有考生未考的总数
     */
    int clearCount(@Param("examId") String examId,@Param("examStatus") Integer examStatus);

    /**
     *获取需要分页所有考生未考的总数
     */
    List<CandidateProcess> clearList(@Param("examId") String examId,@Param("examStatus") Integer examStatus,
                  @Param("startIndex")Integer startIndex,@Param("pageSize") Integer pageSize);

    /**
     * 校验考生试卷表未统分
     * @param examId
     * @return
     */
    Integer unStatisticsScore(String examId);

    /**
     * 过程表分数与答案表总分不一致
     * @param examId
     * @return
     */
    Integer errorScore(String examId);

    /**
     * 空答案有分
     * @param examId
     * @return
     */
    Integer nullAnswerHasScore(String examId);

    /**
     * 正确答案无得分
     * @param examId
     * @return
     */
    Integer correctAnswerHasNotScore(String examId);

    /**
     * 错误答案得分
     * @param examId
     * @return
     */
    Integer errorAnswerHasScore(String examId);

    /**
     * 因故未完成有答案
     * @param examId
     * @return
     */
    Integer noCompleteExamByResonHasAnswer(String examId);

    /**
     * 验证已完成考试未初始化试卷
     * @param examId
     * @return
     */
    Integer finishExamUnInitPaper(String examId);

    /**
     * 验证图片答案题筛查
     * @param examId
     * @return
     */
    Integer pictureAnswerCheck(String examId);

    /**
     * 验证无标答
     * @param examId
     * @return
     */
    Integer noStandardAnswer(String examId);

    /**
     * 验证客观题答案包含http
     * @param examId
     * @return
     */
    Integer objectiveHasHttpError(String examId);

    /**
     * 验证简答题包含http
     * @param examId
     * @return
     */
    Integer shortAnswerHasHttpError(String examId);

    /**
     * 验证填空题包含http
     * @param examId
     * @return
     */
    Integer fillBankAnswerHasHttpError(String examId);

    /**
     * 验证单选或多选题包含数字
     * @param examId
     * @return
     */
    Integer singleOrMultipleHasNum(String examId);

    /**
     *验证单选题长度答案大于1
     * @param examId
     * @return
     */
    Integer singleAnswerLengthMoreThanOne(String examId);

    /**
     * 验证多选题答案错误
     * @param examId
     * @return
     */
    Integer multipleAnswerError(String examId);

    /**
     * 验证判断题答案错误
     * @param examId
     * @return
     */
    Integer judgementAnswerError(String examId);


}
